<%@ WebHandler Language="C#" Class="Search_CS" %>

using System;
using System.Web;
using System.Data.OleDb;
using System.Configuration;
using System.Text;
 
public class Search_CS : IHttpHandler {
   
    public void ProcessRequest (HttpContext context) {
        string prefixText = context.Request.QueryString["q"];
        string strCon = ConfigurationManager.ConnectionStrings["myString"].ConnectionString;
        using (OleDbConnection conn = new OleDbConnection(strCon))
        {
            using (OleDbCommand cmd = new OleDbCommand())
            {
                cmd.CommandText = "select MaDuong,TenDuong from DUONG where " +
                "TenDuong like @SearchText + '%'";
                cmd.Parameters.AddWithValue("@SearchText", prefixText);
                cmd.Connection = conn;
                StringBuilder sb = new StringBuilder();
                conn.Open();
                using (OleDbDataReader sdr = cmd.ExecuteReader())
                {
                    while (sdr.Read())
                    {// 123-ngyvc
                        sb.Append(sdr["MaDuong"] + "-"  + sdr["TenDuong"])
                            .Append(Environment.NewLine);
                    }
                }
                conn.Close();
                context.Response.Write(sb.ToString());
            }
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }
}
//5										,123